package com.shuorikeji.huohuo.ui.me;

import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bytedance.sdk.djx.DJXSdk;
import com.bytedance.sdk.djx.IDJXService;
import com.bytedance.sdk.djx.model.DJXDrama;
import com.bytedance.sdk.djx.model.DJXError;
import com.bytedance.sdk.djx.model.DJXOthers;
import com.google.android.material.imageview.ShapeableImageView;
import com.shuorikeji.huohuo.R;
import com.shuorikeji.huohuo.adapter.BookReadHis1Adapter;
import com.shuorikeji.huohuo.adapter.BookSj1Adapter;
import com.shuorikeji.huohuo.adapter.DjReadHis1Adapter;
import com.shuorikeji.huohuo.adapter.DjSeeJl1Adapter;
import com.shuorikeji.huohuo.adapter.MhReadHis1Adapter;
import com.shuorikeji.huohuo.adapter.MhSj1Adapter;
import com.shuorikeji.huohuo.base.BasePresenterActivity;
import com.shuorikeji.huohuo.bean.BookReadHisMainBean;
import com.shuorikeji.huohuo.bean.BookReadHisSSubBean;
import com.shuorikeji.huohuo.bean.BookSjMainBean;
import com.shuorikeji.huohuo.bean.BookSjSSubBean;
import com.shuorikeji.huohuo.bean.DjHisInfoBean;
import com.shuorikeji.huohuo.bean.DjHisMainBean;
import com.shuorikeji.huohuo.bean.DjSjInfoBean;
import com.shuorikeji.huohuo.bean.DjSjMainBean;
import com.shuorikeji.huohuo.bean.MhReadHisMainBean;
import com.shuorikeji.huohuo.bean.MhReadHisSSubBean;
import com.shuorikeji.huohuo.bean.MhSjMainBean;
import com.shuorikeji.huohuo.bean.MhSjSSubBean;
import com.shuorikeji.huohuo.bean.UserInfoBean;
import com.shuorikeji.huohuo.callback.ClickCallBack;
import com.shuorikeji.huohuo.mvp.AllPresenter;
import com.shuorikeji.huohuo.ui.dj.DjDetailActivity;
import com.shuorikeji.huohuo.ui.dj.DjXqActivity;
import com.shuorikeji.huohuo.ui.fl.TaskGcActivity;
import com.shuorikeji.huohuo.ui.home.BookInfoActivity;
import com.shuorikeji.huohuo.ui.home.HomeActivity;
import com.shuorikeji.huohuo.ui.mh.MhDetailActivity;
import com.shuorikeji.huohuo.ui.sj.SjActivity;
import com.shuorikeji.huohuo.utils.BusinessUtils;
import com.shuorikeji.huohuo.utils.DialogUtil;
import com.shuorikeji.huohuo.utils.JsonUtil;
import com.shuorikeji.huohuo.utils.ToastShowUtil;
import com.shuorikeji.huohuo.view.GridDividerItemDecoration;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

public class MyActivity extends BasePresenterActivity<AllPresenter> {
    @BindView(R.id.iv_msg)
    ImageView ivMsg;
    @BindView(R.id.iv_set)
    ImageView ivSet;
    @BindView(R.id.siv_tx)
    ShapeableImageView sivTx;
    @BindView(R.id.tv_name)
    TextView tvName;
    @BindView(R.id.tv_id)
    TextView tvId;
    @BindView(R.id.ll_user_info)
    LinearLayout llUserInfo;
    @BindView(R.id.ll_my_qb)
    LinearLayout llMyQb;
    @BindView(R.id.ll_tg_center)
    LinearLayout llTgCenter;
    @BindView(R.id.ll_cache_mh)
    LinearLayout llCacheMh;
    @BindView(R.id.ll_fk_wt)
    LinearLayout llFkWt;
    @BindView(R.id.ll_share_app)
    LinearLayout llShareApp;
    @BindView(R.id.tv_ls_tag)
    TextView tvLsTag;
    @BindView(R.id.tv_sc_tag)
    TextView tvScTag;
    @BindView(R.id.tv_dz_tag)
    TextView tvDzTag;
    @BindView(R.id.tv_book_tab)
    TextView tvBookTab;
    @BindView(R.id.tv_mh_tab)
    TextView tvMhTab;
    @BindView(R.id.tv_dj_tab)
    TextView tvDjTab;
    @BindView(R.id.tv_xg)
    TextView tvXg;
    @BindView(R.id.srl_layout_ls_book)
    SmartRefreshLayout srlLsBook;
    @BindView(R.id.rv_data_ls_book)
    RecyclerView rvLsBook;
    @BindView(R.id.ll_tab_1)
    LinearLayout llTab1;
    @BindView(R.id.ll_tab_2)
    LinearLayout llTab2;
    @BindView(R.id.ll_tab_3)
    LinearLayout llTab3;
    @BindView(R.id.ll_tab_4)
    LinearLayout llTab4;
    @BindView(R.id.srl_layout_ls_mh)
    SmartRefreshLayout srlLsMh;
    @BindView(R.id.rv_data_ls_mh)
    RecyclerView rvLsMh;
    @BindView(R.id.srl_layout_ls_dj)
    SmartRefreshLayout srlLsDj;
    @BindView(R.id.rv_data_ls_dj)
    RecyclerView rvLsDj;
    @BindView(R.id.ll_ls_ui)
    LinearLayout llLsUi;
    @BindView(R.id.ll_sc_ui)
    LinearLayout llScUi;
    @BindView(R.id.srl_layout_sc_book)
    SmartRefreshLayout srlScBook;
    @BindView(R.id.rv_data_sc_book)
    RecyclerView rvScBook;
    @BindView(R.id.srl_layout_sc_mh)
    SmartRefreshLayout srlScMh;
    @BindView(R.id.rv_data_sc_mh)
    RecyclerView rvScMh;
    @BindView(R.id.srl_layout_sc_dj)
    SmartRefreshLayout srlScDj;
    @BindView(R.id.rv_data_sc_dj)
    RecyclerView rvScDj;
    @BindView(R.id.ll_dz_ui)
    LinearLayout llDzUi;
    @BindView(R.id.srl_layout_dz_mh)
    SmartRefreshLayout srlDzMh;
    @BindView(R.id.rv_data_dz_mh)
    RecyclerView rvDzMh;
    @BindView(R.id.srl_layout_dz_dj)
    SmartRefreshLayout srlDzDj;
    @BindView(R.id.rv_data_dz_dj)
    RecyclerView rvDzDj;

    private UserInfoBean userInfoBean;
    private int curBookReadHisPage;
    private List<BookReadHisSSubBean> bookReadHisList = new ArrayList<>();
    private BookReadHis1Adapter bookReadHis1Adapter;
    private int mainTabType;//1历史 2收藏 3点赞
    private int subTabType;//1小说 2漫画 3短剧
    private int curLsMhPage;
    private List<MhReadHisSSubBean> mhReadHisList = new ArrayList<>();
    private MhReadHis1Adapter mhReadHis1Adapter;
    private int curLsDjPage;
    private List<DJXDrama> djHisList = new ArrayList<>();
    private DjReadHis1Adapter djReadHis1Adapter;
    private int curBookSjPage;
    private List<BookSjSSubBean> bookSjList = new ArrayList<>();
    private BookSj1Adapter bookSj1Adapter;
    private int curMhSjPage;
    private List<MhSjSSubBean> mhSjList = new ArrayList<>();
    private MhSj1Adapter mhSj1Adapter;
    private int curDjSjPage;
    private List<DjSjInfoBean> djSjList = new ArrayList<>();
    private DjSeeJl1Adapter djSeeJl1Adapter;
    private int curDzDjPage;
    private List<DjSjInfoBean> myLikeDjList = new ArrayList<>();
    private DjSeeJl1Adapter myLikeDjAdapter;
    private Dialog shareAppDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getmImmersionBar().reset().statusBarColor(R.color.transparent).statusBarDarkFont(true, 0.2f).init();
    }

    @Override
    protected void setContentView() {
        setContentView(R.layout.activity_my);
    }

    @Override
    protected void initData() {
        initSmartRefreshLayout();
        initAdapter();
        setTopTab(1);
        setSubTopTab(1);
        curBookReadHisPage = 1;
        getBookReadHis();
        initClick();
    }

    @Override
    protected void onResume() {
        super.onResume();
        userInfoBean = BusinessUtils.getUserInfo();
        setUserInfo();
    }

    private void initSmartRefreshLayout() {
        srlLsBook.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlLsBook.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curBookReadHisPage = 1;
                getBookReadHis();
            }
        });
        srlLsBook.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curBookReadHisPage = curBookReadHisPage + 1;
                getBookReadHis();
            }
        });

        srlLsMh.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlLsMh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curLsMhPage = 1;
                getMhReadHis();
            }
        });
        srlLsMh.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curLsMhPage = curLsMhPage + 1;
                getMhReadHis();
            }
        });

        srlLsDj.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlLsDj.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curLsDjPage = 1;
                getDjSeeHis();
            }
        });
        srlLsDj.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curLsDjPage = curLsDjPage + 1;
                getDjSeeHis();
            }
        });

        srlScBook.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlScBook.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curBookSjPage = 1;
                getBookSjList();
            }
        });
        srlScBook.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curBookSjPage = curBookSjPage + 1;
                getBookSjList();
            }
        });

        srlScMh.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlScMh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curMhSjPage = 1;
                getMhSjList();
            }
        });
        srlScMh.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curMhSjPage = curMhSjPage + 1;
                getMhSjList();
            }
        });

        srlScDj.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlScDj.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curDjSjPage = 1;
                getZjSjList();
            }
        });
        srlScDj.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curDjSjPage = curDjSjPage + 1;
                getZjSjList();
            }
        });

        srlDzMh.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlDzMh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新

            }
        });
        srlDzMh.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多

            }
        });

        srlDzDj.setRefreshHeader(new ClassicsHeader(MyActivity.this));
        srlDzDj.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curDzDjPage = 1;
                getMyLikeDj();
            }
        });
        srlDzDj.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curDzDjPage = curDzDjPage + 1;
                getMyLikeDj();
            }
        });
    }

    private void initAdapter() {
        rvLsBook.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvLsBook.addItemDecoration(new GridDividerItemDecoration(60));
        bookReadHis1Adapter = new BookReadHis1Adapter(MyActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        BookReadHisSSubBean data = (BookReadHisSSubBean) object;
                        Intent intent = new Intent(MyActivity.this, BookInfoActivity.class);
                        intent.putExtra("BOOK_ID", data.getNovel_id());
                        startActivity(intent);
                        break;
                }
            }
        });
        rvLsBook.setAdapter(bookReadHis1Adapter);

        rvLsMh.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvLsMh.addItemDecoration(new GridDividerItemDecoration(60));
        mhReadHis1Adapter = new MhReadHis1Adapter(MyActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        MhReadHisSSubBean data = (MhReadHisSSubBean) object;
                        Intent intent = new Intent(MyActivity.this, MhDetailActivity.class);
                        intent.putExtra("MH_ID", data.getCartoon_id());
                        startActivity(intent);
                        break;
                }
            }
        });
        rvLsMh.setAdapter(mhReadHis1Adapter);

        rvLsDj.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvLsDj.addItemDecoration(new GridDividerItemDecoration(60));
        djReadHis1Adapter = new DjReadHis1Adapter(MyActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        DJXDrama data = (DJXDrama) object;
                        Intent intent = new Intent(MyActivity.this, DjXqActivity.class);
                        intent.putExtra("dramaId", data.id);
                        intent.putExtra("dramaBean", JsonUtil.toJson(data));
                        startActivity(intent);
                        break;
                }
            }
        });
        rvLsDj.setAdapter(djReadHis1Adapter);

        rvScBook.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvScBook.addItemDecoration(new GridDividerItemDecoration(60));
        bookSj1Adapter = new BookSj1Adapter(MyActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        BookSjSSubBean data = (BookSjSSubBean) object;
                        Intent intent = new Intent(MyActivity.this, BookInfoActivity.class);
                        intent.putExtra("BOOK_ID", data.getNovel_id());
                        startActivity(intent);
                        break;
                }
            }
        });
        rvScBook.setAdapter(bookSj1Adapter);

        rvScMh.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvScMh.addItemDecoration(new GridDividerItemDecoration(60));
        mhSj1Adapter = new MhSj1Adapter(MyActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        MhSjSSubBean data = (MhSjSSubBean) object;
                        Intent intent = new Intent(MyActivity.this, MhDetailActivity.class);
                        intent.putExtra("MH_ID", data.getCartoon_id());
                        startActivity(intent);
                        break;
                }
            }
        });
        rvScMh.setAdapter(mhSj1Adapter);

        rvScDj.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvScDj.addItemDecoration(new GridDividerItemDecoration(60));
        djSeeJl1Adapter = new DjSeeJl1Adapter(MyActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        DjSjInfoBean data = (DjSjInfoBean) object;
//                        Intent intent = new Intent(MyActivity.this, DjDetailActivity.class);
//                        intent.putExtra("DJ_ID", data.getVid());
//                        startActivity(intent);

                        Intent intent = new Intent(MyActivity.this, DjXqActivity.class);
                        intent.putExtra("dramaId", data.getVid());
                        intent.putExtra("type", "1");
                        startActivity(intent);
                        break;
                }
            }
        });
        rvScDj.setAdapter(djSeeJl1Adapter);

        rvDzDj.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvDzDj.addItemDecoration(new GridDividerItemDecoration(60));
        myLikeDjAdapter = new DjSeeJl1Adapter(MyActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        DjSjInfoBean data = (DjSjInfoBean) object;
//                        Intent intent = new Intent(MyActivity.this, DjDetailActivity.class);
//                        intent.putExtra("DJ_ID", data.getVid());
//                        startActivity(intent);

                        Intent intent = new Intent(MyActivity.this, DjXqActivity.class);
                        intent.putExtra("dramaId", data.getVid());
                        intent.putExtra("type", "1");
                        startActivity(intent);
                        break;
                }
            }
        });
        rvDzDj.setAdapter(myLikeDjAdapter);
    }

    /**
     * top tab
     *
     * @param flag 1历史
     *             2收藏
     *             3点赞
     */
    private void setTopTab(int flag) {
        if (flag == 3) {
            tvXg.setVisibility(View.GONE);
        } else {
            tvXg.setVisibility(View.VISIBLE);
        }
        mainTabType = flag;
        tvLsTag.setTextColor((flag == 1) ? getResources().getColor(R.color.color_333333) : getResources().getColor(R.color.color_999999));
        BusinessUtils.setTxtFold(tvLsTag, (flag == 1) ? true : false);
        llLsUi.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);

        tvScTag.setTextColor((flag == 2) ? getResources().getColor(R.color.color_333333) : getResources().getColor(R.color.color_999999));
        BusinessUtils.setTxtFold(tvScTag, (flag == 2) ? true : false);
        llScUi.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);

        tvDzTag.setTextColor((flag == 3) ? getResources().getColor(R.color.color_333333) : getResources().getColor(R.color.color_999999));
        BusinessUtils.setTxtFold(tvDzTag, (flag == 3) ? true : false);
        llDzUi.setVisibility((flag == 3) ? View.VISIBLE : View.GONE);
    }

    /**
     * 子分类tab
     *
     * @param flag 1小说
     *             2漫画
     *             3短剧
     */
    private void setSubTopTab(int flag) {
        subTabType = flag;
        if (mainTabType == 3) {
            tvBookTab.setVisibility(View.GONE);
            tvMhTab.setVisibility(View.GONE);
        } else {
            tvBookTab.setVisibility(View.VISIBLE);
            tvMhTab.setVisibility(View.VISIBLE);
            tvBookTab.setBackground((flag == 1) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
            BusinessUtils.setTxtFold(tvBookTab, (flag == 1) ? true : false);
            if (mainTabType == 1) {
                srlLsBook.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);
            } else if (mainTabType == 2) {
                srlScBook.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);
            }
        }

        tvMhTab.setBackground((flag == 2) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvMhTab, (flag == 2) ? true : false);
        if (mainTabType == 1) {
            srlLsMh.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);
        } else if (mainTabType == 2) {
            srlScMh.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);
        } else if (mainTabType == 3) {
            srlDzMh.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);
        }

        tvDjTab.setBackground((flag == 3) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvDjTab, (flag == 3) ? true : false);
        if (mainTabType == 1) {
            srlLsDj.setVisibility((flag == 3) ? View.VISIBLE : View.GONE);
        } else if (mainTabType == 2) {
            srlScDj.setVisibility((flag == 3) ? View.VISIBLE : View.GONE);
        } else if (mainTabType == 3) {
            srlDzDj.setVisibility((flag == 3) ? View.VISIBLE : View.GONE);
        }
    }

    private void setUserInfo() {
        if (userInfoBean != null) {
            BusinessUtils.setLoadImg(MyActivity.this, userInfoBean.getAvatar(), R.mipmap.icon_my_default_tx, sivTx);
            tvName.setText(userInfoBean.getNickname());
            tvId.setText("ID:" + userInfoBean.getUser_id());
        }
    }

    private void getZjSjList() {
        mPresenter.zjJlList(true, 20, curDjSjPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlScDj.finishLoadMore();
                srlScDj.finishRefresh();
                switch (flag) {
                    case 1:
                        DjSjMainBean data = (DjSjMainBean) object;
                        if (curDjSjPage == 1) {
                            djSjList.clear();
                        }
                        djSjList.addAll(data.getData().getData());
                        djSeeJl1Adapter.setData(djSjList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(MyActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getMhSjList() {
        mPresenter.mhSjList(true, 20, curMhSjPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlScMh.finishRefresh();
                srlScMh.finishLoadMore();
                switch (flag) {
                    case 1:
                        MhSjMainBean data = (MhSjMainBean) object;
                        if (curMhSjPage == 1) {
                            mhSjList.clear();
                        }
                        mhSjList.addAll(data.getData().getData());
                        mhSj1Adapter.setData(mhSjList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(MyActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getBookReadHis() {
        mPresenter.bookReadHis(true, 20, curBookReadHisPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlLsBook.finishRefresh();
                srlLsBook.finishLoadMore();
                switch (flag) {
                    case 1:
                        BookReadHisMainBean data = (BookReadHisMainBean) object;
                        if (curBookReadHisPage == 1) {
                            bookReadHisList.clear();
                        }
                        bookReadHisList.addAll(data.getData().getData());
                        bookReadHis1Adapter.setData(bookReadHisList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(MyActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getMhReadHis() {
        mPresenter.mhReadHis(true, 20, curLsMhPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlLsMh.finishLoadMore();
                srlLsMh.finishRefresh();
                switch (flag) {
                    case 1:
                        MhReadHisMainBean data = (MhReadHisMainBean) object;
                        if (curLsMhPage == 1) {
                            mhReadHisList.clear();
                        }
                        mhReadHisList.addAll(data.getData().getData());
                        mhReadHis1Adapter.setData(mhReadHisList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(MyActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getDjSeeHis() {
        DJXSdk.service().getDramaHistory(curLsDjPage, 20, new IDJXService.IDJXCallback<List<? extends DJXDrama>>() {
            @Override
            public void onSuccess(List<? extends DJXDrama> djxDramas, @Nullable DJXOthers djxOthers) {
                srlLsDj.finishLoadMore();
                srlLsDj.finishRefresh();
                if (curLsDjPage == 1) {
                    djHisList.clear();
                }
                djHisList.addAll(djxDramas);
                djReadHis1Adapter.setData(djHisList);
            }

            @Override
            public void onError(@NonNull DJXError djxError) {
                srlLsDj.finishLoadMore();
                srlLsDj.finishRefresh();
                ToastShowUtil.showToastCenter(MyActivity.this, "历史数据获取失败");
            }
        });
//        mPresenter.djSeeJlList(true, 20, curLsDjPage, new ClickCallBack() {
//            @Override
//            public void onClick(int flag, Object object) {
//                srlLsDj.finishLoadMore();
//                srlLsDj.finishRefresh();
//                switch (flag) {
//                    case 1:
//                        DjHisMainBean data = (DjHisMainBean) object;
//                        if (curLsDjPage == 1) {
//                            djHisList.clear();
//                        }
//                        djHisList.addAll(data.getData().getData());
//                        djReadHis1Adapter.setData(djHisList);
//                        break;
//                    case 2:
//                        String msg = (String) object;
//                        ToastShowUtil.showToastCenter(MyActivity.this, msg);
//                        break;
//                }
//            }
//        });
    }

    private void getBookSjList() {
        mPresenter.bookSjList(true, 20, curBookSjPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlScBook.finishLoadMore();
                srlScBook.finishRefresh();
                switch (flag) {
                    case 1:
                        BookSjMainBean data = (BookSjMainBean) object;
                        if (curBookSjPage == 1) {
                            bookSjList.clear();
                        }
                        bookSjList.addAll(data.getData().getData());
                        bookSj1Adapter.setData(bookSjList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(MyActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getMyLikeDj() {
        mPresenter.myLikeDj(true, 20, curDzDjPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlDzDj.finishLoadMore();
                srlDzDj.finishRefresh();
                switch (flag) {
                    case 1:
                        DjSjMainBean data = (DjSjMainBean) object;
                        if (curDzDjPage == 1) {
                            myLikeDjList.clear();
                        }
                        myLikeDjList.addAll(data.getData().getData());
                        myLikeDjAdapter.setData(myLikeDjList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(MyActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void shareAppDialog() {
        shareAppDialog = DialogUtil.showShareAppDialog(MyActivity.this, userInfoBean.getInvite(), new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {

            }
        });
    }

    private void initClick() {
        ivMsg.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, MsgActivity.class);
            startActivity(intent);
        });
        llUserInfo.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, XgUserInfoActivity.class);
            startActivity(intent);
        });
        llFkWt.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, FkWtActivity.class);
            startActivity(intent);
        });
        llTgCenter.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, TgCenterActivity.class);
            startActivity(intent);
        });
        tvLsTag.setOnClickListener(view -> {
            setTopTab(1);
            setSubTopTab(1);
            curBookReadHisPage = 1;
            getBookReadHis();
        });
        tvScTag.setOnClickListener(view -> {
            setTopTab(2);
            setSubTopTab(1);
            curBookSjPage = 1;
            getBookSjList();
        });
        tvDzTag.setOnClickListener(view -> {
            setTopTab(3);
            setSubTopTab(3);
            curDzDjPage = 1;
            getMyLikeDj();
        });
        tvBookTab.setOnClickListener(view -> {
            setSubTopTab(1);
            if (mainTabType == 1) {
                curBookReadHisPage = 1;
                getBookReadHis();
            } else if (mainTabType == 2) {
                curBookSjPage = 1;
                getBookSjList();
            }
        });
        tvMhTab.setOnClickListener(view -> {
            setSubTopTab(2);
            if (mainTabType == 1) {
                curLsMhPage = 1;
                getMhReadHis();
            } else if (mainTabType == 2) {
                curMhSjPage = 1;
                getMhSjList();
            } else if (mainTabType == 3) {

            }
        });
        tvDjTab.setOnClickListener(view -> {
            setSubTopTab(3);
            if (mainTabType == 1) {
                curLsDjPage = 1;
                getDjSeeHis();
            } else if (mainTabType == 2) {
                curDjSjPage = 1;
                getZjSjList();
            } else if (mainTabType == 3) {
                curDzDjPage = 1;
                getMyLikeDj();
            }
        });
        llShareApp.setOnClickListener(view -> {
            shareAppDialog();
        });
        tvXg.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, SjActivity.class);
            startActivity(intent);
            finish();
        });
        ivSet.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, SetActivity.class);
            startActivity(intent);
        });
        llMyQb.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, MyQbActivity.class);
            startActivity(intent);
        });
        llTab1.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, HomeActivity.class);
            startActivity(intent);
            finish();
        });
        llTab2.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, SjActivity.class);
            startActivity(intent);
            finish();
        });
        llTab3.setOnClickListener(view -> {
            Intent intent = new Intent(MyActivity.this, TaskGcActivity.class);
            startActivity(intent);
            finish();
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        BusinessUtils.clearDialog(shareAppDialog);
    }
}